using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace QuanLySimDienThoai
{
    public partial class Form1 : Form
    {
        
        public Form1()
        {
            InitializeComponent();
        }
       
        private void btnDangNhap_Click(object sender, EventArgs e)
        {
            frmDangNhap DangNhap = new frmDangNhap();
            if (btnDangNhap.Text == "Đăng Nhập")
            {
                DangNhap.ShowDialog();
            }
            if (DangNhap.KIEMTRADANGNHAP == true)
            {
                btnDangNhap.Text = "Đăng Xuất";
                btnQuanLySim.Visible = true;
            }
            else
            {
                btnDangNhap.Text = "Đăng Nhập";
                MessageBox.Show("Đã đăng xuất");
                btnQuanLySim.Visible = false;
            }
        }

        private void btnQuanLySim_Click(object sender, EventArgs e)
        {
            frmQuanLySim qlSim = new frmQuanLySim();
            qlSim.ShowDialog();
        }

        private void btnTimKiem_Click(object sender, EventArgs e)
        {
            frmTimKiem timkiem = new frmTimKiem();
            timkiem.ShowDialog();
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            DialogResult resul = MessageBox.Show("Thoát khỏi chương trình?", "Quản Lý Sim - Thoát", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (resul == DialogResult.Yes)
            {
                this.Dispose();
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                SqlConnection conn = new SqlConnection("Server=ITQUANGNAM\\SQLEXPRESS;Integrated security=SSPI;database=master");
                conn.Open();
            }
            catch (Exception ex) { MessageBox.Show(ex.ToString()); }
        }
    }
}